package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Zonghechengji;
import com.ruoyi.system.service.IZonghechengjiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 综合成绩Controller
 * 
 * @author ruoyi
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/school/zonghechengji")
public class ZonghechengjiController extends BaseController
{
    @Autowired
    private IZonghechengjiService zonghechengjiService;

    /**
     * 查询综合成绩列表
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:list')")
    @GetMapping("/list")
    public TableDataInfo list(Zonghechengji zonghechengji)
    {
        startPage();
        List<Zonghechengji> list = zonghechengjiService.selectZonghechengjiList(zonghechengji);
        return getDataTable(list);
    }

    /**
     * 导出综合成绩列表
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:export')")
    @Log(title = "综合成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Zonghechengji zonghechengji)
    {
        List<Zonghechengji> list = zonghechengjiService.selectZonghechengjiList(zonghechengji);
        ExcelUtil<Zonghechengji> util = new ExcelUtil<Zonghechengji>(Zonghechengji.class);
        util.exportExcel(response, list, "综合成绩数据");
    }

    /**
     * 获取综合成绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zonghechengjiService.selectZonghechengjiById(id));
    }

    /**
     * 新增综合成绩
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:add')")
    @Log(title = "综合成绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Zonghechengji zonghechengji)
    {
        return toAjax(zonghechengjiService.insertZonghechengji(zonghechengji));
    }

    /**
     * 修改综合成绩
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:edit')")
    @Log(title = "综合成绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Zonghechengji zonghechengji)
    {
        return toAjax(zonghechengjiService.updateZonghechengji(zonghechengji));
    }

    /**
     * 删除综合成绩
     */
    @PreAuthorize("@ss.hasPermi('school:zonghechengji:remove')")
    @Log(title = "综合成绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zonghechengjiService.deleteZonghechengjiByIds(ids));
    }
}
